package com.tr.rentcar.controller.goods;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;
import com.tr.rentcar.model.bean.CarComment;
import com.tr.rentcar.model.dao.CarCommentDao;

@WebServlet("/commentpage")
public class CommentPageController extends HttpServlet {

	/**
	 * 评论分页
	 */
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		int cid=Integer.parseInt(req.getParameter("cid"));
		int pageno=Integer.parseInt(req.getParameter("pageno"));
		try {
			List<CarComment> commectList=new CarCommentDao().getAll(cid, (pageno-1)*5, 5);
			resp.getWriter().println(JSONArray.toJSONString(commectList));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
